import { service } from "../http/request";
import {baseURL} from "../utils/download";

/**
 * 獲取所有員工 分頁
 */
const getAllEmp = (currentPage,size,params,beginDateScope) => {
  return service({
    method: 'get',
    url: `/employee/basic/?currentPage=${currentPage}&size=${size}&name=${params.name}&politicId=${params.politicId}&nationId=${params.nationId}&departmentId=${params.departmentId}&posId=${params.posId}&beginDateScope=${beginDateScope}`
  })
}

/**
 * 获取职位
 */
const getPositions = () => {
  return service({
    method: 'get',
    url: '/employee/basic/positions'
  })
}

/**
 * 获取职称
 */
const getJobLevels = () => {
  return service({
    method: 'get',
    url: '/employee/basic/joblevels'
  })
}

/**
 * 获取政治面貌
 */
const getPolitics = () => {
  return service({
    method: 'get',
    url: '/employee/basic/politicsstatus'
  })
}

/**
 * 获取民族
 */
const getNations = () => {
  return service({
    method: 'get',
    url: '/employee/basic/nations'
  })
}

/**
 * 获取最大工号
 */
const getMaxWorkId = () => {
  return service({
    method: 'get',
    url: '/employee/basic/maxWorkID'
  })
}

/**
 * 获取所有部门
 */
const getAllDeps = () => {
  return service({
    method: 'get',
    url: '/employee/basic/deps'
  })
}

/**
 * 添加员工
 */
const addEmp = (params) => {
  return service({
    method:'post',
    url: '/employee/basic/',
    data: params
  })
}

/**
 * 删除员工
 */
const deleteEmp = (id) => {
  return service({
    method: 'delete',
    url: `/employee/basic/${id}`,
  })
}

/**
 * 更新员工
 */
const updateEmp = (params) => {
  return service({
    method: 'put',
    url: '/employee/basic/',
    data: params
  })
}

/**
 * 文件上传
 */
const uploadUrl = `${baseURL}employee/basic/import`;
// const uploadFile = (file) => {
//   return service({
//     method: 'POST',
//     url: 'employee/basic/import',
//     data: file
//   })
// }

export default {
  getAllEmp,
  getPolitics,
  getNations,
  getJobLevels,
  getPositions,
  getMaxWorkId,
  getAllDeps,
  addEmp,
  deleteEmp,
  updateEmp,
  uploadUrl
}
